package com.taptech.doufu.ui.view.choice.adapter;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;

import androidx.viewpager.widget.PagerAdapter;


public class ChoiceViewPagerAdapter extends PagerAdapter {
    private List<View> viewList;
    private List<String> titles;

    public ChoiceViewPagerAdapter(List<View> viewList, List<String> titles) {
        this.viewList = viewList;
        this.titles = titles;
    }

    @Override
    public int getCount(){
        // TODO Auto-generated method stub
        if (viewList != null) {
            return viewList.size();
        }
        return 0;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
        container.removeView(viewList.get(position));
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(viewList.get(position ));
        return viewList.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }
}